package user;

/**
 * Created with IntelliJ IDEA.
 * User: prog1c2
 * Date: 28.03.13
 * Time: 9:35
 * To change this template use File | Settings | File Templates.
 */
public class User {

    private int age;
    private String name;

    public User(int age, String name) {
        this.age = age;
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }


    @Override
    public boolean equals(Object anObject) {
        if (this == anObject) {
            return true;
        }
        if (anObject instanceof User) {
            User anotherUser = (User) anObject;
            if (age == anotherUser.age && name.equals(anotherUser.name)) {
                return true;
            }
        }
        return false;
    }

    @Override
    public int hashCode() {
        return  13*age + 17*name.hashCode();
                //super.hashCode();
    }

    @Override
    public String toString() {
        return String.format("User age=%d name=%s", age, name);
    }


}
